import unittest
from AStock.ASSetting import ASSetting, settings_path
import os


class TestSetting(unittest.TestCase):

    def testSetting(self):
        s = ASSetting()
        self.assertEqual(s.mongo_uri, 'mongodb://127.0.0.1:27017')
        self.assertTrue(os.path.exists(os.path.join(settings_path, 'config.ini')))

        # 填入一个可用的mongodb uri
        s = ASSetting(mongo_uri='mongodb://root:xxx@xxxx:27017')
        self.assertIsNotNone(s.client)
        db_list = s.client.list_database_names()
        print('db list: {}'.format(' '.join(db_list)))
